#include <cstdlib>
#include "Matrix.h"
#include "ImageFilter.h"
#include "ImageFilterList.h"
#include "BoxBlurFilter.h"
#include "DesaturateFilter.h"
#include "ImageIO.h"

void print(Matrix* matrix)
{
	for(int i = 0; i< matrix->getHeight(); i++)
	{
		for(int j = 0; j< matrix->getWidth(); j++)
		{
			std::cout<<" "<< matrix->getValue(j, i) <<" ";

			if(j == matrix->getWidth()-1)
			{
				std::cout<< std::endl;
			}
		}
	}
}
void main()
{
	//Matrix* matrix = new Matrix(2,2);
	//Matrix* matrix2 = new Matrix(3,3);

	//matrix->setValue(0,0, 1.0f);
	//matrix->setValue(1,0, 2.0f);
	//matrix->setValue(2,0, 3.0f);
	//matrix->setValue(0,1, 4.0f);
	//matrix->setValue(1,1, 5.0f);
	//matrix->setValue(2,1, 6.0f);
	//matrix->setValue(0,2, 7.0f);
	//matrix->setValue(1,2, 8.0f);
	//matrix->setValue(2,2, 9.0f);

	//matrix2->setValue(0,0, 1.0f);
	//matrix2->setValue(1,0, 2.0f);
	//matrix2->setValue(2,0, 3.0f);
	//matrix2->setValue(0,1, 4.0f);
	//matrix2->setValue(1,1, 5.0f);
	//matrix2->setValue(2,1, 6.0f);
	//matrix2->setValue(0,2, 7.0f);
	//matrix2->setValue(1,2, 8.0f);
	//matrix2->setValue(2,2, 9.0f);

	//matrix2->setValue(0,0, 2.0f);
	//matrix2->setValue(1,0, 2.0f);
	//matrix2->setValue(2,0, 2.0f);
	//matrix2->setValue(0,1, 3.0f);
	//matrix2->setValue(1,1, 3.0f);
	//matrix2->setValue(2,1, 3.0f);
	//matrix2->setValue(0,2, 1.0f);
	//matrix2->setValue(1,2, 2.0f);
	//matrix2->setValue(2,2, 3.0f);

	//std::cout<<"Original Matrices:"<<std::endl;
	//print(matrix);
	//std::cout<<std::endl;
	//print(matrix2);

	//matrix->setDimensions(5,8);
	//std::cout<<std::endl;
	//std::cout<<"Redimensioned matrix:"<<std::endl;
	//print(matrix);

	//std::cout<<std::endl;
	//std::cout<<"Matrix addition:"<<std::endl;
	//matrix->add( (*matrix2) );
	//print(matrix);

	//std::cout<<std::endl;
	//std::cout<<"Matrix multiplication:"<<std::endl;
	//matrix->multiply( (*matrix2) );
	//print(matrix);

	//std::cout<<std::endl;
	//std::cout<<"Matrix transpose:"<<std::endl;
	//matrix->transpose( );
	//print(matrix);


	//system("pause");

	//delete(matrix);

	
	Image image;

	ImageIO imageIO;

	ImageFilterList imageFilterList;

	BoxBlurFilter blurFilter(11);

	DesaturateFilter desaturateFilter;
	
	//imageFilterList.addImageFilter(&blurFilter);
	imageFilterList.addImageFilter(&desaturateFilter);
	//imageFilterList.addImageFilter(&blurFilter);

	bool load = imageIO.load("VISIT.tga", image);

	if(load)
	{

		//blurFilter.apply(image);

		//Image* bluredImage = blurFilter.getBluredImage();

		//imageIO.save("VISIT_Blur.tga", *bluredImage);

		//desaturateFilter.apply(image);
		//imageIO.save("VISIT_Desaturate.tga", image);

		imageFilterList.apply(image);

		//imageIO.save("VISIT_Blur.tga", image);
		imageIO.save("VISIT_Desaturate.tga", image);

		std::cout<<"Done"<<std::endl;
	}
	else
	{
		std::cout<<"NOT LOADED"<<std::endl;
	}

	system("pause");

}